home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / Updates / PowerPC / pdflib / bind / java / hello.java next >
Text File  |  2000-05-16  |  972b  |  44 lines

  1. /* hello.java
  2.  * Copyright (C) 1997-99 Thomas Merz. All rights reserved.
  3.  *
  4.  * PDFlib client: hello example in Java
  5.  */
  6.  
  7. public class hello
  8. {
  9.     public static void main (String argv[])
  10.     {
  11.     long p;
  12.     int font;
  13.  
  14.     p = pdflib.PDF_new();
  15.  
  16.     if (pdflib.PDF_open_file(p, "hello_java.pdf") == -1) {
  17.         System.err.println("Couldn't open PDF file hello_java.pdf\n");
  18.         System.exit(1);
  19.     }
  20.  
  21.     pdflib.PDF_set_info(p, "Creator", "hello.java");
  22.     pdflib.PDF_set_info(p, "Author", "Thomas Merz");
  23.     pdflib.PDF_set_info(p, "Title", "Hello world (Java)");
  24.  
  25.     pdflib.PDF_begin_page(p, 595, 842);
  26.  
  27.     font = pdflib.PDF_findfont(p, "Helvetica-Bold", "default", 0);
  28.     if (font == -1){
  29.         System.err.println("Couldn't find font!\n");
  30.         System.exit(1);
  31.     }
  32.  
  33.     pdflib.PDF_setfont(p, font, 18);
  34.  
  35.     pdflib.PDF_set_text_pos(p, 50, 700);
  36.     pdflib.PDF_show(p, "Hello world!");
  37.     pdflib.PDF_continue_text(p, "(says Java)");
  38.     pdflib.PDF_end_page(p);
  39.  
  40.     pdflib.PDF_close(p);
  41.     pdflib.PDF_delete(p);
  42.     }
  43. }
  44.